package com.ciwong.epaper.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.SeekBar;

import com.ciwong.epaper.R;

/**
 * Created by neo on 2016/7/29.
 */
public class ListenSpeakPlayerBottomUI extends FrameLayout {


    protected View rlSkin;

    private TextTimerView mTextTimerView;

    private SeekBar seek_bar_timer;

    private  boolean setMax=false;

    public ListenSpeakPlayerBottomUI(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public ListenSpeakPlayerBottomUI(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public ListenSpeakPlayerBottomUI(Context context) {
        super(context);

        init(context);

    }


    protected void init(Context context) {
//		UI 分层
        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        rlSkin =  LayoutInflater.from(getContext()).inflate(R.layout.listen_speak_player_bottom, null);
        addView(rlSkin, params);
        mTextTimerView = (TextTimerView) findViewById(R.id.vnew_text_duration_ref);
        seek_bar_timer = (SeekBar) findViewById(R.id.seek_bar_timer);
    }


    public void setTextTimer(long position,long duration)
    {
        mTextTimerView.setTextTimer(position,duration);
        if (!setMax) {
            seek_bar_timer.setMax((int) duration-1);
            setMax=true;
        }
        seek_bar_timer.setProgress((int) position);
    }


    public void setOnFullScreenListener(View.OnClickListener listen) {
        findViewById(R.id.btn_full_screen).setOnClickListener(listen);
    }


    public void disableFullScreen() {
        findViewById(R.id.btn_full_screen).setVisibility(GONE);
    }
}
